Where named values live in the Code tab, how to make one, and how the Build sky gradient button (in the Overlay Effects tab) turns three colors into a sky you can name and reuse.
A macro gives a number or a color a name. You write the name in your code, and when the game is built the name is swapped for the value, everywhere you wrote it.
#macro CELL 8After that line, CELL means 8. If one day the cells should be 16 wide, you change that one line and the whole game follows. A macro never runs and nothing ever calls it. It is only a name.
Because nothing calls a macro, macros do not belong in a script (a script is something you call). They have a section of their own: Macros, in the Code tab, under Room Creation Code. The in-editor Help Center topic covers the same ground from the buttons' side.
Click Macros in the list on the left of the Code tab. Each row is one macro, with its name and its value. Click a row to see it in the text.
| Button | What it does |
|---|---|
| + | Makes a new named value: type a name and a value. |
| ✎ | Opens every macro as text in a window, to type them directly. |
Right-click a row to change it, show it in the text, or delete it. A sky shows as a row of three color blocks; the button that builds one is in the Overlay Effects tab (see below).
Only two things belong in this section: #macro lines, and comments (lines that start with //). If you write anything else here, such as a function or a line like hp = 5;, the Problems list says so, because nothing in this section ever runs.
A name can use letters, numbers and _, and cannot start with a number. It cannot be a name the game already uses, like an object, a script, a picture, or something built in. The dialogs tell you when a name is taken.
The macros are saved in one file at the top of your project folder, called macros.gbml. A project that never uses the section has no such file.
A sky is three colors: one for the top of the screen, one for the middle and one for the bottom. The console blends them into a smooth sky behind everything else (see screen_backdrop_gradient). The button that builds one is in the Overlay Effects tab, in the Sky color section, because that tab is where skies live. A sky of three colors that never changes is the cheaper way to get a sky; use the Sky color track for a sky that changes or moves.
SKY_DUSK.#1F3A7C in the box, or click a swatch under Colors from your game to borrow a color your pictures already use.Now write the name where the three colors would go:
screen_backdrop_gradient(SKY_DUSK);It does exactly what writing the three colors out would do, and you can change the sky in one place.
The dialog writes one macro, with a comment above it that says where it came from:
// Made by the Build sky gradient button. Change it there, not here - a sky needs exactly three colors.
#macro SKY_DUSK #1F3A7C, #7A3F8F, #F2A65AA sky is just a macro with exactly three colors in a row. That is how Gbabel finds all your skies again, with nothing else to keep in step. If you edit the line by hand so that it no longer has three colors, it stops being a sky, and screen_backdrop_gradient tells you it needs three.
The console keeps 32 levels of each color, so a color is rounded a little. The preview shows the rounded colors, which is what the game will show.
When you open Build sky gradient (Overlay Effects tab, Sky color section) it lists every sky your project has, each as a small strip of its three colors. The same strips show in the Macros section's list.
Making, changing or deleting a macro is one step you can undo with Ctrl+Z. The buttons save the file right away. Text you type in the window waits for Ctrl+S, like any code.
Some older projects kept their named values in a script with nothing but #macro lines in it. That still works, and the game builds exactly the same. But because nothing calls such a script, it looks like a mistake.
If a script holds only macros, Gbabel offers to move them: right-click the script and choose Move to Macros section, or press Move to Macros under the Macros heading. The script is removed and its lines go into the section, comments and all. Undo brings the script back.
#macro line. Move it into a script or an object's event.screen_backdrop_gradient does not hold three colors in a row. Fix the line, or build it again with the Build sky gradient button.screen_backdrop_gradient(SKY_DUSK), and write a single color on its own if you need just one.